﻿<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<meta name="renderer" content="webkit|ie-comp|ie-stand">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
<!--[if lt IE 9]>
<script type="text/javascript" src="__STATIC__/lib/html5shiv.js"></script>
<script type="text/javascript" src="__STATIC__/lib/respond.min.js"></script>
<![endif]-->
<link rel="stylesheet" type="text/css" href="__STATIC__/h-ui/css/H-ui.min.css" />
<link rel="stylesheet" type="text/css" href="__STATIC__/h-ui.admin/css/H-ui.admin.css" />
<link rel="stylesheet" type="text/css" href="__STATIC__/lib/Hui-iconfont/1.0.8/iconfont.css" />
<link rel="stylesheet" type="text/css" href="__STATIC__/h-ui.admin/skin/default/skin.css" id="skin" />
<link rel="stylesheet" type="text/css" href="__STATIC__/h-ui.admin/css/style.css" />
<!--[if IE 6]>
<script type="text/javascript" src="__STATIC__/lib/DD_belatedPNG_0.0.8a-min.js" ></script>
<script>DD_belatedPNG.fix('*');</script>
<![endif]-->
<title>品牌管理</title>

</head>

<body>
<nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 首页 <span class="c-gray en">&gt;</span> 产品管理 <span class="c-gray en">&gt;</span> 品牌管理 <a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新" ><i class="Hui-iconfont">&#xe68f;</i></a></nav>
<div class="page-container">
	<div class="text-c">
		<form class="Huiform" method="post" enctype="multipart/form-data" action="insert" target="_self">
			<input type="text" placeholder="分类名称" name="brand_name" value="" class="input-text" style="width:120px">
			<span class="btn-upload form-group">
			<input class="input-text upload-url" name="brand_logo" type="text" hidden id="uploadfile-2" readonly style="width:200px">
			<a href="javascript:void();" class="btn btn-primary upload-btn"><i class="Hui-iconfont">&#xe642;</i> 上传logo</a>
			<input type="file" multiple name="brand_logo" class="input-file">
			</span> 
			<span class="select-box" style="width:150px">	
				<select class="select" name="brand_type" size="1">
				 <?php foreach ($list as $key => $val){ ?>
					<option value="<?php echo $val['type_id'] ?>"><?php echo str_repeat("&nbsp;&nbsp;", $val['f']) ?><?php echo $val['type_name'] ?></option>
				<?php } ?>
				</select>
			</span>
            <input type="hidden" name="brand_show" value="0">
				<input type="text" placeholder="描述信息..." name="brand_desc" value="" class="input-text" style="width:300px">
		
			<button type="submit" class="btn btn-success" id="" name="" onClick="picture_colume_add(this);"><i class="Hui-iconfont">&#xe600;</i> 添加</button>
		</form>
	</div>

<!-- 批量删除 -->
	<div class="cl pd-5 bg-1 bk-gray mt-20"> 
	   <span class="l">
	     <a href="javascript:;"onclick="delAll()" id="delAll" class="btn btn-danger"> 
	         批量删除
	     </a>

	   </span>  
	</div>


	<div class="mt-20">
		<table class="table table-border table-bordered table-bg table-sort">
			<thead>
				<tr class="text-c">
					<th width="25"><input type="checkbox" id="yi" value=""></th>
					<th width="70">ID</th>
					<!-- <th width="80">排序</th> -->
					<th width="200">LOGO</th>
					<th width="120">品牌名称</th>
					<th>具体描述</th>
					<th width="60">发布状态</th>
					<th width="100">操作</th>
				</tr>
			</thead>
			<tbody>


			<?php foreach ($data as $key => $val){ ?>
				<tr class="text-c" >

					<td><input class="er" name="id" type="checkbox" value="<?php echo $val['brand_id'] ?>"></td>
					<td><?php echo $val['brand_id'] ?></td>
					<!-- <td><input type="text" class="input-text text-c" value="<?php echo $val['brand_id'] ?>"></td> -->
					<td><img src="__ROOT__/<?php echo $val['brand_logo'] ?>" width="110" heigth="30" alt=""></td>
					<td class="text-l"><img src="__ROOT__/<?php echo $val['brand_logo'] ?>" width="50" heigth="10" alt=""> <?php echo $val['brand_name'] ?></td>
					<td class="text-l"><?php echo $val['brand_desc'] ?></td>
					<td class="td-status">

					
					
					<?php if ($val['brand_show']==0){ ?>
					  <span class="label label-success radius change" value="1" where ="<?php echo $val['brand_id'] ?>">已发布</span>
					<?php }?>

					<?php else{ ?>
					   <span class="label label-success radius change" value="0" where ="<?php echo $val['brand_id'] ?>">未发布</span>
					<?php } ?>
						
                         <!-- defaunt -->
                        <!--  <select name="" class="change" xuigai="<?php echo $val['brand_id'] ?>">
                         	<option <?php echo $val['brand_show']==0 ?'selected':'' ?> value="0" >未发布</option>
                         	<option <?php echo $val['brand_show']==1 ?'selected':'' ?> value="1">已发布</option>
                         </select> -->
					</td>
					<td class="f-14 product-brand-manage"><a style="text-decoration:none" onClick="product_brand_edit('品牌编辑','codeing.html','1')" href="update_show?brand_id=<?php echo $val['brand_id'] ?>" title="编辑"><i class="Hui-iconfont">&#xe6df;</i></a>

					 <a style="text-decoration:none" class="ml-5" onClick="active_del(this,'10001')" href="delete?brand_id=<?php echo $val['brand_id'] ?>" title="删除"><i class="Hui-iconfont">&#xe6e2;</i></a>

					 <!--  <a style="text-decoration:none" class="ml-5" onClick="product_del(this,'10001')" href="delete?brand_id=<?php echo $val['brand_id'] ?>" title="删除"><i class="Hui-iconfont">&#xe6e2;</i></a> -->
					</td>
				</tr>
			<?php } ?>
			</tbody>
		</table>
	</div>
</div>
<!--_footer 作为公共模版分离出去-->
<script type="text/javascript" src="__STATIC__/lib/jquery/1.9.1/jquery.min.js"></script>
<script type="text/javascript" src="__STATIC__/lib/layer/2.4/layer.js"></script>
<script type="text/javascript" src="__STATIC__/static/h-ui/js/H-ui.min.js"></script>
<script type="text/javascript" src="__STATIC__/static/h-ui.admin/js/H-ui.admin.js"></script> <!--/_footer 作为公共模版分离出去-->

<!--请在下方写此页面业务相关的脚本-->
<script type="text/javascript" src="__STATIC__/lib/My97DatePicker/4.8/WdatePicker.js"></script>
<script type="text/javascript" src="__STATIC__/lib/datatables/1.10.0/jquery.dataTables.min.js"></script>
<script type="text/javascript" src="__STATIC__/lib/laypage/1.2/laypage.js"></script>
<script type="text/javascript">
$('.table-sort').dataTable({
	"aaSorting": [[ 1, "desc" ]],//默认第几个排序
	"bStateSave": true,//状态保存
	"aoColumnDefs": [
	  //{"bVisible": false, "aTargets": [ 3 ]} //控制列的隐藏显示
	  {"orderable":false,"aTargets":[0,6]}// 制定列不参与排序
	]
});
	$(document).on("click","#yi",function(){
		if($(this).prop("checked")){
           $(".er").prop("checked",true);
		}else{
           $(".er").prop("checked",false);
		}
	});
	//批删
	$(document).on("click","#delAll",function(){  
        var idstr="";  
        $(".er").each(function(i,x){  
            if(x.checked){  
                idstr += ","+x.value;  
                
            }  
        })  
       //alert(idstr);die;
        $.ajax({
            url:"{:URL('index/brand/delall')}",
            data:{brand_id:idstr},
            type:"get",
            success:function(res){
                if(res==1){
                   location.href=location.href;
                }
            }
         })  

      
	})
	//极点极改
	$(document).on("click",".change",function(){  
     var brand_show = $(this).attr('value')
     var brand_id = $(this).attr('where')
     // var ax=$(this).attr('class');

     var _this = $(this)
      $.ajax({
      	 url:"{:URL('index/brand/ajaxgai')}",
      	 data:{brand_id:brand_id,brand_show:brand_show},
      	 type:"post",
      	 success:function(res){
            console.log(res);
            if(res=='0'){
              _this.empty();
              _this.text("已发布");
              _this.attr('value',1);
              alert(_this.text());
             //_this.attr('class',label label-success radius);
            }else{
              _this.empty();
              _this.text("未发布");
              _this.attr('value',0);
              alert(_this.text());
              //_this.attr('class',label label-defaunt radius);
            }
      	 }
      })
	})
	function product_del(obj,id){
	layer.confirm('确认要删除吗？',function(index){
		$.ajax({
			type: 'POST',
			url: '',
			dataType: 'json',
			success: function(data){
				$(obj).parents("tr").remove();
				layer.msg('已删除!',{icon:1,time:1000});
			},
			error:function(data) {
				console.log(data.msg);
			},
		});		
	});
}
</script>
</body>
</html>